package bank
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.DisplayObject;
	import flash.filters.GlowFilter;
	import flash.geom.ColorTransform;

	public class ChestTool
	{
		[Embed(source = "bank/mine.png")]
		private static var MineBut:Class;
		
		[Embed(source = "bank/refresh.png")]
		private static var RefreshBut:Class;
		
		[Embed(source = "bank/stole.png")]
		private static var StoleClass:Class;
		
		public static var stole:BitmapData = (new StoleClass).bitmapData;
		
		[Embed(source = "bank/take.swf")]
		public static var TakeAnimate:Class;
		
		
		public static const CHEST_STATE_INVALID:int = 0;
		public static const CHEST_STATE_ACTIVATE:int = 1;
		public static const CHEST_STATE_EMPTY:int = 2;
		public static const CHEST_STATE_STORE:int = 3;
		public static const CHEST_STATE_HAVEST:int = 4;
			
	
		[Embed(source="bank/smallBoard.png")]
		private static var SmallBoardClass:Class;
		
		[Embed(source="bank/bigBoard.png")]
		private static var BigBoardClass:Class;
		
		
		public static var smallBoard:Bitmap = new SmallBoardClass();
		public static var bigBoard:Bitmap = new BigBoardClass();
		
		
		[Embed(source="bank/chest1close.png")]
		private static var Chest1CloseClass:Class;
		
		[Embed(source="bank/chest1open.png")]
		private static var Chest1OpenClass:Class;

		[Embed(source="bank/chest2close.png")]
		private static var Chest2CloseClass:Class;
		
		[Embed(source="bank/chest2open.png")]
		private static var Chest2OpenClass:Class;
		
		
		public static var chest1close:Bitmap = new Chest1CloseClass();
		public static var chest1open:Bitmap = new Chest1OpenClass();
		public static var chest2close:Bitmap = new Chest2CloseClass();
		public static var chest2open:Bitmap = new Chest2OpenClass();
		
		[Embed(source="bank/chestGold1.swf")]
		public static var Chest1Gold:Class;
		
		[Embed(source="bank/chestGold2.swf")]
		public static var Chest2Gold:Class;
		
		public static const TYPE_IRON:int = 0;
		public static const TYPE_COPPER:int = 1;
		public static const TYPE_SILVER:int = 2;
		public static const TYPE_GOLD:int = 3;
		public static const TYPE_PLATINUM:int = 4;
		public static const TYPE_JADE:int = 5;
		public static const TYPE_STONE:int = 6;
		public static const TYPE_DIAMOND:int = 7;
		
		
		
		public static const CHEST_CASE_TYPE_0:int = 0;
		public static const CHEST_CASE_TYPE_1:int = 1;
		
		private static var ironTrans:ColorTransform =     new ColorTransform(1,1,1,1,0,-40,-80,0);//钢铁
		private static var copperTrans:ColorTransform =   new ColorTransform(1,1,1,1,-10,-10,-150,0);//铜
		private static var silverTrans:ColorTransform =   new ColorTransform(1,1,1,1,5,0,-45,0);//白银
		private static var goldTrans:ColorTransform =     new ColorTransform(1,1,1,1,40,-40,-255,0);//黄金
		private static var platinumTrans:ColorTransform = new ColorTransform(1,1,1,1,0,0,30,0);//铂金
		private static var jadeTrans:ColorTransform =     new ColorTransform(1,1,1,1,20,40,-11,0);//玉石
		private static var stoneTrans:ColorTransform =    new ColorTransform(1,1,1,1,0,-130,-174,0);//宝石
		private static var diamondTrans:ColorTransform =  new ColorTransform(1,1,1,1,-130,-30,40,0);//钻石
		
		public static function setChestColor(target:DisplayObject,type:int):void
		{
			switch(type)
			{
				case TYPE_IRON:
					target.transform.colorTransform = ironTrans;
					break;
				case TYPE_SILVER:
					target.transform.colorTransform = silverTrans;
					break;
				case TYPE_COPPER:
					target.transform.colorTransform = copperTrans;
					break;
				case TYPE_GOLD:
					target.transform.colorTransform = goldTrans;
					break;
				case TYPE_PLATINUM:
					target.transform.colorTransform = platinumTrans;
					break;
				case TYPE_JADE:
					target.transform.colorTransform = jadeTrans;
					break;
				case TYPE_STONE:
					target.transform.colorTransform = stoneTrans;
					break;
				case TYPE_DIAMOND:
					target.transform.colorTransform = diamondTrans;
					break;
			}
		}
		private static var blackTrans:ColorTransform = new ColorTransform(0,0,0,1,0,0,0,0);
		private static var blueTrans:ColorTransform = new ColorTransform(1,1,1,1,-255,255,0,0);
		
		public static function blackBoard(target:DisplayObject):void
		{
			target.transform.colorTransform = blackTrans;
		}
		
		public static function blueBoard(target:DisplayObject):void
		{
			target.transform.colorTransform = blueTrans;
		}
		
		private static var glowFilter:GlowFilter = new GlowFilter(0xFFFFFF,1,18,18);
		
		public static function glowChest(chest:DisplayObject):void
		{
			chest.filters = [glowFilter];
		}
		
		
	}
}